import datetime
from typing import Optional

from pydantic import BaseModel


class BeidianCloudDeviceData(BaseModel):
    runningWord: str = None  # 0400 80, // 状态字
    monthPrepaidBalance: str = None  # 0.00,
    monthSubsidyBalance: str = None  # 0.00, // 本月累计用补助金额
    prepaidBalance: str = None  # 0.10, // 付费余额
    voltage: str = None  # 230.3, // 实时电压
    frequency: str = None  # 49.98, // 电网频率
    switchWord: str = None  # 0020, // 开关字
    reserveData: str = None  # 000000000000000000000000000000000000000000000000000000000000000000000000000000000000, // 预留数据
    current: str = None  # 0.012, // 实时电流
    totalElectricEnergy: str = None  # 0.09, // 组合有功总电能
    todayOpenTime: str = None  # 0, // 当日空调开机时间
    temperature: str = None  # 28.1, // 环境温度
    subsidyBalance: str = None  # 0.00, // 补助余额
    chargeBalance: str = None  # 0.10, // 剩余金额
    monthTotalPower: str = None  # 0.09, // 本月累计总用电量
    reportTime: str = None  # 2024 - 0  9 - 28 20: 18:03,
    activePower: str = None  # 0.0006 // 有功功率
    status: str = None
    updateDateTime: str = None


class DeviceData:
    code: str = ""
    airConditionId: int
    airConditioningStatus: int  # 运行 1    关机 2  故障 3
    electricCurrent: int
    dataTime: datetime.datetime
    currentTemp: int  # 当前温度 10进制格式0-51，0x0012表示18度
    mode: int  # 模式 00 制冷 01 采暖 02 通风
    speed: int  # 风速 01 低速 02 中速 03 高速
    todayTime: int # 分钟
    monthTotalPower: int# 本月累计总用电量


class CommonReport(BaseModel):
    # name: str
    # age: int
    # address: str
    # salary: float
    reportType: str  # '0605',
    devNo: str  # 240715027398,
    deviceData: BeidianCloudDeviceData
    checkToken: str  # U0hkdW9sb25nLDE3Mjc1MjU4ODQsZmM5YzJjODU0ZThkMTFlMjlhNjg0ZjA2MTI5NjRkYzVmZTJmNWMzNjdjNTYwNWRiMzg3YWMwYWZlYWQwN2ZhMQ==,
    deviceId: str  # d5ae9baf-0d06-4bbd-90b6-e95f1a512aed,
    productType: str  # KT.XXX.XBXXX,
    reportTime: str  # '2024-09-28 20:18:04'


class CommonResponse():
    methodContent: str  #:"infrared_instruction_multi",
    methodType: str  # "air_conditioning_contro",
    commandId: str  # "b7a4cb58-7f1f-480a-8948-8ff1a90d125c",
    devNo: str  # "191216006915",
    productType: str  # "PZCZ051",
    resultParams: dict


class Command(BaseModel):
    devNo: str  # "191216006915",
    params: Optional[dict] = dict()
    switch: Optional[str] = None
